<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{padding: 50px;}
        #div1{background-color: aqua;}
        #div2{background-color: blue;}
        #div3{background-color: red;}
    </style>
    <script>
        window.onload = function(){
            var oDiv = document.getElementsByTagName("div")
            for(var i = 0;i<oDiv.length;i++)
            {
                oDiv[i].onclick = function(ev){
                    var e = ev||window.event
                    alert(this.id)
                    stopBubble(e)
                }
            }
        }

        function stopBubble(e){
            if(e.stopPropagation){
                e.stopPropagation()
            }else{
                e.cancelBubble = true
            }
        }
    </script>
</head>
<body>
    <div id = "div1">
        <div id = "div2">
            <div id = "div3"></div>
        </div>
    </div>
</body>
</html>